/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Com.agenceLocation.bdd;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Yohan
 */
@Entity
@Table(name = "LOCATION")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Location.findAll", query = "SELECT l FROM Location l"),
    @NamedQuery(name = "Location.findById", query = "SELECT l FROM Location l WHERE l.id = :id"),
    @NamedQuery(name = "Location.findByStartdate", query = "SELECT l FROM Location l WHERE l.startdate = :startdate"),
    @NamedQuery(name = "Location.findByEnddate", query = "SELECT l FROM Location l WHERE l.enddate = :enddate"),
    @NamedQuery(name = "Location.findByPrice", query = "SELECT l FROM Location l WHERE l.price = :price"),
    @NamedQuery(name = "Location.findByReturndate", query = "SELECT l FROM Location l WHERE l.returndate = :returndate"),
    @NamedQuery(name = "Location.findByPenality", query = "SELECT l FROM Location l WHERE l.penality = :penality")})
public class Location implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "STARTDATE")
    @Temporal(TemporalType.DATE)
    private Date startdate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ENDDATE")
    @Temporal(TemporalType.DATE)
    private Date enddate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PRICE")
    private double price;
    @Column(name = "RETURNDATE")
    @Temporal(TemporalType.DATE)
    private Date returndate;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "PENALITY")
    private Double penality;
    @JoinColumn(name = "VEHICULE_ID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Vehicule vehiculeId;
    @JoinColumn(name = "CLIENTID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Client clientid;

    public Location() {
    }

    public Location(Integer id) {
        this.id = id;
    }

    public Location(Integer id, Date startdate, Date enddate, double price) {
        this.id = id;
        this.startdate = startdate;
        this.enddate = enddate;
        this.price = price;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getStartdate() {
        return startdate;
    }

    public void setStartdate(Date startdate) {
        this.startdate = startdate;
    }

    public Date getEnddate() {
        return enddate;
    }

    public void setEnddate(Date enddate) {
        this.enddate = enddate;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public Date getReturndate() {
        return returndate;
    }

    public void setReturndate(Date returndate) {
        this.returndate = returndate;
    }

    public Double getPenality() {
        return penality;
    }

    public void setPenality(Double penality) {
        this.penality = penality;
    }

    public Vehicule getVehiculeId() {
        return vehiculeId;
    }

    public void setVehiculeId(Vehicule vehiculeId) {
        this.vehiculeId = vehiculeId;
    }

    public Client getClientid() {
        return clientid;
    }

    public void setClientid(Client clientid) {
        this.clientid = clientid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Location)) {
            return false;
        }
        Location other = (Location) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Com.agenceLocation.bdd.Location[ id=" + id + " ]";
    }
    
}
